Let $\mathbf{R}$ be the matrix for reflecting over the vector $\begin{pmatrix} 3 \\ 1 \end{pmatrix}.$  Find $\mathbf{R}^2.$
Solution: Let $\mathbf{v}$ be an arbitrary vector, and let $\mathbf{r}$ be the reflection of $\mathbf{v}$ over $\begin{pmatrix} 3 \\ 1 \end{pmatrix},$ so $\mathbf{r} = \mathbf{R} \mathbf{v}.$

[asy]
unitsize(1 cm);

pair D, P, R, V;

D = (3,1);
V = (1.5,2);
R = reflect((0,0),D)*(V);
P = (V + R)/2;

draw((-1,0)--(4,0));
draw((0,-1)--(0,3));
draw((0,0)--D,Arrow(6));
draw((0,0)--V,red,Arrow(6));
draw((0,0)--R,blue,Arrow(6));
draw(V--R,dashed);

label("$\mathbf{v}$", V, NE);
label("$\mathbf{r}$", R, SE);
[/asy]

Then the reflection of $\mathbf{r}$ is $\mathbf{v},$ so $\mathbf{R} \mathbf{r} = \mathbf{v}.$  Thus,
\[\mathbf{v} = \mathbf{R} \mathbf{r} = \mathbf{R}^2 \mathbf{v}.\]Since this holds for all vectors $\mathbf{v},$ $\mathbf{R}^2 = \mathbf{I} = \boxed{\begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}}.$